package com.example.tetstmybatis.controller;

import com.example.tetstmybatis.domain.Test1;
import com.example.tetstmybatis.service.TestService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
@RequestMapping("/test")
@RestController
public class Testlist {
    @Resource
    private TestService testService;
    @GetMapping("/list")
    public List<Test1> testlistall(){
        return  testService.list();
  }
  @GetMapping("/query")
    public Test1 testQuery(int id){
        return testService.queryById(id);
  }

  @PostMapping("/add")
    public boolean addtest(Test1 test1){
      boolean addtest = testService.addtest(test1);
      return addtest;
  }
  @PostMapping("/updatetest")
    public boolean update(Test1 test1){
      boolean b = testService.updateTest(test1);
      return  b;
  }

  @GetMapping("/deletetest")
    public  boolean deltest(int id){
      boolean b = testService.deleteTest(id);
      return b;
  }
}
